import { DECIMAL_TYPES, INT_TYPES } from 'src/pages/AnalyseManage/EditReport/components/EditorDataType/EnumConfig';
import React from 'react';

const colorBlue = { color: '#167DDC' };
const colorGreen = { color: '#87BD25' };

interface IProps{
	dataType: string;
}

const FieldComponent = ( props: IProps ) => {
	const { dataType } = props;
	if ( [ 'TIME' ].indexOf( dataType.toUpperCase() ) !== -1 ) {
		// 时间
		return <span className={'iconfont bdhshijianriqi'} style={ colorBlue }></span>;
	} else if ( [ 'DATE', 'DATETIME', 'TIMESTAMP' ].indexOf( dataType.toUpperCase() ) !== -1 ) {
		// 日期
		return <span className={'iconfont bdhshijianriqi'} style={ colorBlue }></span>;
	} else if ( INT_TYPES.indexOf( dataType.toUpperCase() ) !== -1 ) {
		// 整数
		return <span className={'iconfont bdhzhengshu'} style={ colorGreen }></span>;
	} else if ( DECIMAL_TYPES.indexOf( dataType.toUpperCase() ) !== -1 ) {
		// 小数
		return <span className={'iconfont bdhzhengshubeifen'} style={ colorBlue }></span>;
	} else {
		// 字符串文本
		return <span className={'iconfont bdhwenben'} style={ colorGreen }></span>;
	}
};

export default React.memo( FieldComponent );